package org.xiaodongwei.jvm.op;

import org.xiaodongwei.jvm.exe.JVMStack;
import tech.medivh.classpy.classfile.bytecode.Instruction;
import tech.medivh.classpy.classfile.constant.ConstantPool;
import tech.medivh.classpy.classfile.jvm.Opcode;

public class IReturnOpCodeExecute extends OpCodeExecute {

    public IReturnOpCodeExecute(JVMStack jvmStack, ConstantPool constantPool) {
        this.opCode = Opcode.ireturn;
        this.jvmStack = jvmStack;
        this.constantPool = constantPool;
    }

    @Override
    public void execute(Instruction instruction) {
        int result = (int) this.jvmStack.peek().getOperateStack().pop();
        jvmStack.pop();
        jvmStack.peek().pushToOperateStack(result);
    }
}
